(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 8.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       157,          7]
NotebookDataLength[     14286,        345]
NotebookOptionsPosition[     12795,        300]
NotebookOutlinePosition[     13174,        316]
CellTagsIndexPosition[     13131,        313]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{

Cell[CellGroupData[{
Cell["Fuel Tank G", "Section",
 CellChangeTimes->{{3.568289149358963*^9, 3.5682891675710044`*^9}, {
   3.5682892846807027`*^9, 3.568289303122758*^9}, {3.568354108266954*^9, 
   3.568354108970954*^9}, 3.56846401697423*^9}],

Cell[BoxData[
 RowBox[{"<<", "C:\\\\Hopsan\\Compgen\\CompgenNG.mx"}]], "Input",
 CellChangeTimes->{{3.5772037650720577`*^9, 3.5772037650780582`*^9}, {
  3.611474457184202*^9, 3.611474523938877*^9}, {3.6114745588913717`*^9, 
  3.61147456057154*^9}}],

Cell[BoxData[
 RowBox[{"path", "=", 
  RowBox[{"ToFileName", "[", 
   RowBox[{"{", 
    RowBox[{
    "\"\<C:\>\"", ",", "\"\<HopsanTrunk\>\"", ",", 
     "\"\<ComponentLibraries\>\"", ",", "\"\<defaultLibrary\>\"", ",", 
     "\"\<Special\>\"", ",", "\"\<Aerocomponents\>\"", ",", 
     "\"\<FuelComponents}];\>"}]}]}]}]], "Input",
 CellChangeTimes->{{3.5757727777685804`*^9, 3.575772792541806*^9}, {
   3.5757728423954945`*^9, 3.5757728498367076`*^9}, {3.57577333888545*^9, 
   3.5757733706315055`*^9}, 3.5757734316206255`*^9, 3.6031909973287797`*^9, 
   3.6057717887213297`*^9, {3.605771829393656*^9, 3.605771830929744*^9}, 
   3.6058530990363216`*^9, {3.621138851005574*^9, 3.621138863716845*^9}, {
   3.626164321826791*^9, 3.626164327986407*^9}, {3.6327778035174313`*^9, 
   3.6327778156381245`*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"p0", "=."}], ";", 
  RowBox[{"T", "=."}], ";"}]], "Input",
 CellChangeTimes->{{3.568355078809949*^9, 3.568355082456949*^9}, {
  3.6327779100075226`*^9, 3.63277791101558*^9}}],

Cell[BoxData[{
 RowBox[{
  RowBox[{"displayName", "=", "\"\<FuelTankG\>\""}], ";"}], "\n", 
 RowBox[{
  RowBox[{
  "brief", "=", "\"\<Calulates the mass of remaining fuel in tank\>\""}], 
  ";"}], "\n", 
 RowBox[{
  RowBox[{"componentType", "=", "\"\<ComponentC\>\""}], ";"}], "\n", 
 RowBox[{
  RowBox[{"domain", "=", "\"\<Hydraulic\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"author", "=", "\"\<Petter Krus <petter.krus@liu.se>\>\""}], 
  ";"}], "\n", 
 RowBox[{
  RowBox[{
  "affiliation", " ", "=", " ", 
   "\"\<Division of Fluid and Mechatronic Systems, Link\[ODoubleDot]ping \
University\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"SetFilenames", "[", 
   RowBox[{"path", ",", "domain", ",", "displayName"}], "]"}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{"ResetComponentVariables", "[", "]"}]}], "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.},
 CellChangeTimes->{{3.522429929546875*^9, 3.522429972765625*^9}, {
   3.5224301489375*^9, 3.522430155421875*^9}, 3.53189964671875*^9, 
   3.5411602015417213`*^9, 3.5682878446963406`*^9, 3.5682879350195065`*^9, {
   3.5682885691497765`*^9, 3.5682885755821447`*^9}, {3.568289258601211*^9, 
   3.568289274044094*^9}, {3.5685259622875643`*^9, 3.568525962456581*^9}, 
   3.5757721208896084`*^9}],

Cell[TextData[{
 "Simple model of fuel tank\n\n",
 Cell[GraphicsData["Metafile", "\<\
CF5dJ6E]HGAYHf4PEfU^I6mgLb15CDHPAVmbKF5d0@0000AP0@000?@0001Xo_ooZOkookP100090P00
00000000001]1000R`d00215CDH00040H0@003<000030000@`0006`000000000EPD00003003R0@00
3`40000000000000000006IJ1`1E8P@0B@1^06/0L`1S0640L01U0200<00^03@0>00^0380801b03T0
>00a03T0800X0440M@1W0200<@0d0200<P0`0340<@0Y0000J@1^06/0L`1S0640L01U02d0H`1/06T0
L01R06l0H@1b06@0;@1U07P0L01_0780M00^06D0K@1V000000000140000<0000200000T0000@0000
K@@008/=000;000040000200001R0000AP0002P0000L0000Df=bIFE^?C4c=SIh=cHhL7P/83@h<WPb
=c5]KDH0000/00007P0004AbHGMYKVLm<2h`N2d`;S1`N2`P<2h`N2d`;S1]K@009`0001P000010000
00000?ooo`0000009@0000`0000100004`0000`000020000G`0003P000020000>0000000000h0000
000000020@0O0000000000000000000000000000000U000030000080000k0000200001/0000@0000
4P000140000f0000400005`4000A0000=P000100001L1000h`L003H0000@00004P000><7000m0000
200003`000080000?`0001P0003oooooooooob80000k00009@0000`000000020:00000`000010000
9@0000`000070020:00000`0000200009`0001P000020000000009VIV@0000009@0000`000020000
4`0000`000020000G`0003P000010000>0000000000h0000000000020@0M00000000000000000000
00000000000U000030000040000k0000200001/0000@00003`000903000f0000400005h4002@0`00
=P000100001N1000>0/003H0000@00003`0003P;000m0000200003`000080000?`0001P0003noooo
60000280001C00009@0000`000000020:00000`0000200009@0000`000070020:00000`000010000
G`0003P000010000>0000000000h00000000000R0@0U0000000000000000000000000000000U0000
30000040000j0000300001X1000k0000200001/0000@0000>`8003D;000f0000400003/2001h3@00
?00000P000100000600006SnoonYo_oo^04000T2000U0000300000L0080X000030000040000>0000
50000000000@00005000
\>"], "Graphics",
  GeneratedCell->False,
  CellAutoOverwrite->False,
  ImageSize->{89., 277.5952380952381},
  ImageMargins->{{0, 0}, {0, 147}}],
 "\n"
}], "Text",
 CellChangeTimes->{{3.632777681336443*^9, 3.632777752369506*^9}, {
  3.6327778548883696`*^9, 3.632777862747819*^9}}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{
  RowBox[{"inputParameters", "  ", "=", " ", 
   RowBox[{"{", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
      "rhofuel", ",", "700.", ",", "double", ",", "\"\<kg/m3\>\"", ",", 
       "\"\<Fuel density\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{
      "p0", ",", "100000.", ",", "double", ",", "\"\<Pa\>\"", ",", 
       "\"\<tank pressure\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{
      "hf", ",", "5.", ",", "double", ",", "\"\<m/s2\>\"", ",", 
       "\"\<fuel in tank height\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{
      "massfuel0", ",", "1000.", ",", "double", ",", "\"\<kg/s\>\"", ",", 
       "\"\<The intitial fuel mass\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{
      "massfuelmax", ",", "1000.", ",", "double", ",", "\"\<kg\>\"", ",", 
       "\"\<fuelmass at full tank\>\""}], "}"}]}], "\n", "}"}]}], 
  ";"}]], "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.},
 CellChangeTimes->{{3.522430004390625*^9, 3.522430004390625*^9}, 
   3.5224300528125*^9, 3.53189964671875*^9, 3.5411602015417213`*^9, {
   3.568288043176693*^9, 3.5682880662150106`*^9}, 3.5682892740450945`*^9, 
   3.568292752092027*^9, {3.5682930742664547`*^9, 3.5682930760485563`*^9}, {
   3.5682931161188483`*^9, 3.568293122857234*^9}, 3.5682932165005903`*^9, {
   3.568293382808102*^9, 3.568293392842676*^9}, {3.5682941132878833`*^9, 
   3.5682941831208773`*^9}, 3.578630221535854*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"inputVariables", "  ", "=", " ", 
   RowBox[{"{", "\[IndentingNewLine]", 
    RowBox[{"{", 
     RowBox[{
     "gx", ",", "9.82", ",", "double", ",", "\"\<m/s2\>\"", ",", 
      "\"\<acceleration\>\""}], "}"}], "\n", "}"}]}], ";"}]], "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.},
 CellChangeTimes->{{3.52242999471875*^9, 3.52242999471875*^9}, 
   3.522430053078125*^9, 3.53189964671875*^9, 3.5411602015417213`*^9, {
   3.5682876302290735`*^9, 3.5682877946604786`*^9}, {3.5682882333545704`*^9, 
   3.5682882358947153`*^9}, {3.5682886272571*^9, 3.568288653534603*^9}, 
   3.5682892740450945`*^9, 3.568292725770522*^9, {3.5682930721653347`*^9, 
   3.568293092591503*^9}, {3.5682941454817247`*^9, 3.568294158898492*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"outputVariables", "  ", "=", " ", 
   RowBox[{"{", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
      "massfuel", ",", "0.", ",", "double", ",", "\"\<kg\>\"", ",", 
       "\"\<Fuel mass\>\""}], "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"{", 
      RowBox[{
      "consfuel", ",", "0.", ",", "double", ",", "\"\<kg\>\"", ",", 
       "\"\<Consumed fuel mass\>\""}], "}"}]}], "\[IndentingNewLine]", 
    "}"}]}], ";"}]], "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.},
 CellChangeTimes->{{3.522429987234375*^9, 3.522429987234375*^9}, {
   3.522430053296875*^9, 3.522430053515625*^9}, 3.53189964671875*^9, 
   3.5411602015417213`*^9, {3.568288026761754*^9, 3.5682880387684402`*^9}, 
   3.5682892740450945`*^9, {3.5682927178650694`*^9, 3.568292720943246*^9}, {
   3.568294193220455*^9, 3.568294212625565*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"nodeConnections", "=", 
   RowBox[{"{", "\[IndentingNewLine]", "\t", 
    RowBox[{"HydraulicCnode", "[", 
     RowBox[{"T", ",", 
      RowBox[{"1.", "*", 
       RowBox[{"10", "^", "5"}]}], ",", "\"\<fluid port\>\""}], "]"}], 
    "\[IndentingNewLine]", "}"}]}], ";"}]], "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.},
 CellChangeTimes->{{3.5682878998394947`*^9, 3.5682879233968415`*^9}, {
   3.568287993950877*^9, 3.568287997705092*^9}, 3.5682892740450945`*^9, 
   3.5682926047145977`*^9}],

Cell[BoxData[
 RowBox[{
  RowBox[{"systemEquationsDA", " ", "=", " ", 
   RowBox[{"{", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"Der", "[", "consfuel", "]"}], "\[Equal]", 
     RowBox[{
      RowBox[{"-", "qT"}], " ", "rhofuel"}]}], "\[IndentingNewLine]", "}"}]}],
   ";"}]], "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.},
 CellChangeTimes->{
  3.52328838171875*^9, 3.53189964671875*^9, 3.5411602015417213`*^9, {
   3.554784526954604*^9, 3.5547845283608723`*^9}, {3.5682880956096916`*^9, 
   3.568288136340021*^9}, 3.5682892740450945`*^9, 3.5682941032823105`*^9, {
   3.571904238058652*^9, 3.5719042464826665`*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"systemVariables", " ", "=", " ", 
   RowBox[{"{", "consfuel", "}"}]}], ";"}]], "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.},
 CellChangeTimes->{{3.52243007746875*^9, 3.522430082921875*^9}, 
   3.53189964671875*^9, 3.5411602015417213`*^9, 3.5682892740450945`*^9}]
}, Open  ]],

Cell[BoxData[
 RowBox[{
  RowBox[{"eps", "=", "0.0001"}], ";"}]], "Input",
 CellChangeTimes->{{3.5683618419854927`*^9, 3.5683618458528795`*^9}, 
   3.568362544247712*^9, 3.5757161800928535`*^9}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{
  RowBox[{"expressions", " ", "=", 
   RowBox[{"{", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"massfuel", "==", 
      RowBox[{"massfuel0", "-", "consfuel"}]}], ",", "\[IndentingNewLine]", 
     RowBox[{"hx", "==", 
      RowBox[{"hf", " ", 
       RowBox[{"massfuel", "/", "massfuelmax"}]}]}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"cT", "==", 
      RowBox[{
       RowBox[{"onPositive", "[", "massfuel", "]"}], 
       RowBox[{"(", 
        RowBox[{
         RowBox[{"gx", " ", "hx", " ", "rhofuel"}], "+", "p0"}], ")"}]}]}], 
     ",", "\[IndentingNewLine]", 
     RowBox[{"ZcT", "==", "0."}]}], "\[IndentingNewLine]", "}"}]}], 
  ";"}]], "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.},
 CellChangeTimes->{{3.531857777953125*^9, 3.531857802140625*^9}, 
   3.53189964671875*^9, 3.5411602015417213`*^9, {3.5682878067211685`*^9, 
   3.568287840213084*^9}, {3.568287961346012*^9, 3.56828796532324*^9}, {
   3.5682881691398973`*^9, 3.5682882757739964`*^9}, {3.568288593104147*^9, 
   3.568288622826847*^9}, 3.5682892740460944`*^9, {3.568294321359784*^9, 
   3.5682943233889008`*^9}, 3.5682948834179325`*^9, {3.5683540392219543`*^9, 
   3.568354093826954*^9}, {3.568361833726667*^9, 3.5683618391222067`*^9}, 
   3.5683622303453245`*^9, {3.568362408783167*^9, 3.568362411892478*^9}, {
   3.5684640626592293`*^9, 3.5684640689062295`*^9}, {3.568526594043439*^9, 
   3.568526660113439*^9}, 3.5685267047884393`*^9, {3.5685270954124393`*^9, 
   3.5685270961704392`*^9}, 3.568528138195278*^9, {3.568528205104278*^9, 
   3.568528209485278*^9}, {3.571904189246166*^9, 3.5719042292602367`*^9}, {
   3.5719255395812054`*^9, 3.5719255402520065`*^9}}],

Cell[BoxData[
 RowBox[{
  RowBox[{"variableLimits", "=", 
   RowBox[{"{", 
    RowBox[{"{", 
     RowBox[{"consfuel", ",", "0.", ",", 
      RowBox[{"massfuel0", "+", "eps"}]}], "}"}], "}"}]}], ";"}]], "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.},
 CellChangeTimes->{
  3.53189964671875*^9, 3.5411602015417213`*^9, 3.5682892740460944`*^9, {
   3.568362236516942*^9, 3.568362266461936*^9}, {3.5683623093072205`*^9, 
   3.568362311379428*^9}, {3.568362428788167*^9, 3.5683624290691953`*^9}, {
   3.568362530576345*^9, 3.568362530871374*^9}, 3.571904272409912*^9}],

Cell[BoxData[
 RowBox[{"Compgen", "[", "file", "]"}]], "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.},
 CellChangeTimes->{3.53189964671875*^9, 3.5411602015417213`*^9, 
  3.5682892740460944`*^9}]
}, Open  ]]
}, Open  ]]
},
WindowSize->{707, 505},
WindowMargins->{{Automatic, 223}, {Automatic, 33}},
Magnification->0.8999999761581421,
FrontEndVersion->"8.0 for Microsoft Windows (64-bit) (October 6, 2011)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[579, 22, 221, 3, 63, "Section"],
Cell[803, 27, 248, 4, 27, "Input"],
Cell[1054, 33, 804, 15, 46, "Input"],
Cell[1861, 50, 209, 5, 27, "Input"],
Cell[2073, 57, 1291, 30, 154, "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.}],
Cell[3367, 89, 1926, 31, 310, "Text"],
Cell[CellGroupData[{
Cell[5318, 124, 1570, 33, 136, "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.}],
Cell[6891, 159, 767, 14, 64, "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.}],
Cell[7661, 175, 888, 19, 82, "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.}],
Cell[8552, 196, 540, 12, 64, "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.}],
Cell[9095, 210, 639, 14, 64, "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.}],
Cell[9737, 226, 313, 6, 27, "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.}]
}, Open  ]],
Cell[10065, 235, 194, 4, 27, "Input"],
Cell[CellGroupData[{
Cell[10284, 243, 1692, 33, 118, "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.}],
Cell[11979, 278, 577, 12, 27, "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.}],
Cell[12559, 292, 208, 4, 27, "Input",
 CellGroupingRules->{GroupTogetherGrouping, 10000.}]
}, Open  ]]
}, Open  ]]
}
]
*)

(* End of internal cache information *)
